<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改密码</title>
<link rel="stylesheet" type="text/css" href="css/css.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<style type="">
	.bbD{
		width:600px;
	}
	.input3{
		width:280px;
	}
	span{
		width:140px;
	}
</style>
<script type="text/javascript">

	/* 验证旧密码是否与本系统登陆一致*/
	function checkpwd1(){
		$("#pwdinfo").html("");
		var password=$("#pwd").val();
		var id=$("#id").val(); 
		if(password==null || ""==password){
			$("#pwdinfo").html("密码不能为空").css({color:"red"});
			return false;
		}else{
			$.ajax({
				url:"empByIdAndPwd.do",
				type:"POST",
				dataType:"JSON",
				data:{"id":id,"password":password},
				success:function(result){
					if(result.res=="true"){
						$("#pwdinfo").html("请输入新密码").css({color:"green"});
						return true;
					}
					if(result.res=="false"){
						$("#pwdinfo").html("密码输入错误").css({color:"red"});
						return false;
					}
				}
			});
		}
		return true;	
	}
	/* 第二次输入密码进行格式要求设置  */
	function checkPwd2(){
		var newpwdinfo=$("#newpwdinfo").html("");
		var password=$("#pwd2").val();
		if(password==null || ""==password){
			$("#newpwdinfo").html("密码不能为空").css({color:"red"});
			return false;
		}else if(password.length<6 || password.length>18){
			$("#newpwdinfo").html("密码必须6到18位").css({color:"red"});
			return false;
		}else
			$("#newpwdinfo").html("密码可以用").css({color:"green"});
			return true;
	}
	function checkPwd3(){
		$("#repwdinfo").html("");
		var pwd2=$("#pwd2").val();
		var pwd3=$("#pwd3").val();
		if(pwd2==pwd3){
			$("#repwdinfo").html("两次输入密码一致").css({color:"green"});
			return true;
		}else{
			$("#repwdinfo").html("两次输入密码不一致").css({color:"red"});
			return false;
		}
	}
	/* 三次验证必须同为真才可以提交  */
	function isExit(){
		if(checkpwd1() && checkPwd3() && checkPwd2()){
			return true;
		}else{
			return false;
		}
	} 
	
</script>
</head>
<body>
	<div id="pageAll">
		<div class="pageTop">
			<div class="page">
				<img src="img/coin02.png" /><span><a href="main.do">首页</a>&nbsp;-&nbsp;-<a
					href="changepwd.do">系统管理</a>&nbsp;-</span>&nbsp;-修改密码
			</div>
		</div>
		<div class="page">
		<form action="pwdEmpById.do" method="post" onsubmit="return isExit()">
			<!-- 修改密码页面样式 -->
			<div class="bacen">
					<input type="text"  style="display:none"  class="input3" id="id" name="id" value="${user.id}" />  
				<div class="bbD">&nbsp;&nbsp;当前登录名：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${user.username}</div>
				<div class="bbD">
					&nbsp;&nbsp;&nbsp;输入旧密码：<input type="password" class="input3"
						onblur="checkpwd1()" id="pwd" /><span id="pwdinfo"></span> 
				</div>
				<div class="bbD">
					&nbsp;&nbsp;&nbsp;输入新密码：<input type="password" name="password" class="input3" id="pwd2" onblur="checkPwd2()"/> 
						<span id="newpwdinfo"></span> 
				</div>
				<div class="bbD">
					再次确认密码：<input type="password" class="input3" id="pwd3" onblur="checkPwd3()" /> 
					<span id="repwdinfo"></span> 
				</div>
				<div class="bbD">
					<p class="bbDP">
						<input type="submit" class="btn_ok btn_yes"/><!--提交  -->
						<input type="reset" class="btn_ok btn_yes" /><!-- 重置 -->
					</p>
				</div>
			</div>
			<!-- 修改密码页面样式end -->
		</form>
		</div>
	</div>
</body>

</html>